<?php
include('inc_head.php');
$tag=$wu->request_string('tag');
if(!$tag) 		die('参数有误');
$id=$wu->request_int('id');
$itemid=$wu->request_int('itemid');
$itemidargs=$itemid?"&itemid=$itemid":'';
if($wu->request_string('act')=='del' && $id){
	$db->delete('tgeneralarticle',"ID=$id");
	$wu->redirect('删除成功','article_list.php?tag='.$tag.$itemidargs);
}
?>
<div style="margin:5px;"><a href="article_edit.php?tag=<?php echo $tag.$itemidargs; ?>">新增文章</a></div>
<table class="table table-hover table-bordered">
    <thead>
        <tr><th>序号</th><th>标题</th><th>分类</th><th>发布时间</th><th>操作</th></tr>
    </thead>
    <tbody>
	<?php
		$i=1;
		$sqlitemid=$itemid?" ItemID=$itemid and ":'';
		$rs=$db->fetch_all("select a.*,b.Name as CatalogName from tgeneralarticle a left join tgeneralcatalog b on a.CatalogID=b.ID where $sqlitemid a.ExTags='$tag'");
		if($rs){
		foreach($rs as $row){
			echo '<tr><td>'.$i.'</td><td>'.$row['Title'].'</td><td>'.$row['CatalogName'].'</td><td>'.$row['CreatedTime'].'</td><td><a href="article_edit.php?tag='.$tag.'&id='.$row['ID'].$itemidargs.'">编辑</a> <a href="?tag='.$tag.'&act=del&id='.$row['ID'].$itemidargs.'">删除</a></td></tr>';
			$i++;
		}
		}
	?>
    </tbody>
    <tfoot>
        <tr class="warning"><td colspan="5">-</td></tr>
    </tfoot>
</table>
<?php
	include('inc_foot.php');
?>
